package com.itheima.common;

public class BaseContext {

    private static final ThreadLocal<Long> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 将登录成功的员工id存入到ThreadLocal中
     * @param id
     */
    public static void setCurrentId(Long id){
        THREAD_LOCAL.set(id);
    }

    /**
     * 从ThreadLocal中获取当前线程共享的登录用户id
     * @return
     */
    public static Long getCurrentId(){
        return THREAD_LOCAL.get();
    }
}
